<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script type="text/javascript">
       //js中的数组是可变长的 
       let  array = [ '张三' ,"李四" ,"王五"  ,100,200 ,[1,2,3,4]      ]
        //int array[] = { 100,200,300,"张思"} 


        array[array.length] = 999;
        array[array.length] = 888;
        // array[100] = 999;

        // 长度
        // console.log('array.length: ',array.length);
        // for(let i=0 ;i<array.length ;i++){
        //     console.log("array["+i+"] = "+(array[i]));
        // }



        //数组

        // 队列的方式操作
        //  尾  进入------------------------>头  出
        // let array1 =  [] 
        // let array1 =  new Array() 
        // array1.push(100)
        // array1.push(200)
        // array1.push(300)

        // console.log(array1);
        // console.log("===============================");
        // console.log("shift"+array1.shift(),array1);
        // console.log("shift"+array1.shift(),array1);
        
        // let array2 =  new Array() 
        // array2.push(100)
        // array2.push(200)
        // array2.push(300)
        // console.log(array2);

        // console.log("===============================");

        // console.log("pop:"+array2.pop(),array2);
        // console.log("pop:"+array2.pop(),array2);
        // console.log("pop:"+array2.pop(),array2);


        //排序
        // https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
        // https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted
        // let array3 = [ 100,20,35,88,90,26]
        // console.log("array3 ",array3);
        // //修改源数组
        // console.log("array3.toSorted: ",array3.sort((a,b)=>{
        //     return a-b;
        // }));
        // console.log("array3 -old ",array3);



        // //排序
        // let array4 = [ 100,20,45,88,90,26]
        // console.log("array4 ",array4);

        // //不修改源数组
        // console.log("array4.toSorted: ",array4.toSorted((a,b)=>{
        //     return a-b;
        // }));
        // console.log("array4 -old ",array4);


        // let  arr5 = [   100,200,300]
        // console.log("arr5-reverse beofre : ",arr5);
        // console.log("arr5.reverse()",arr5.reverse());
        // console.log("arr5-reverse after : ",arr5);

        
        //  let  arr5 = [   100,200,300]
        // console.log("arr5-reverse beofre : ",arr5);
        // console.log("arr5.toReversed()",arr5.toReversed());
        // console.log("arr5-reverse after : ",arr5);



        //连接多个数组
        let array6 = [1,2,3,4];
        let array7 = [5,6,7,8];
        // let concatArray = array6.concat(array7)
        // console.log("concatArray: ",concatArray);


        // ES6
        // let concatArray = [...array6,...array7]
        // console.log("concatArray: ",concatArray);

        // let joinResult = concatArray.join("#")
        // console.log("concatArray.join('#''): ",joinResult);
        // console.log("typoef concatArray.join('#''): ",typeof(joinResult));




        // let numsStr =  "zhangsan---lisi---王五"

        // console.log('numsStr.split("---")',numsStr.split("---"));
        // console.log('numsStr.split("---")[0]',numsStr.split("---")[0]);
        // console.log('numsStr.split("---")[1]',numsStr.split("---")[1]);
        // console.log('numsStr.split("---")[2]',numsStr.split("---")[2]);

        

        // let array8 = [1,2,3,4,5,6,7,8,9]

        // console.log("array8: ",array8);
        // array8.splice(1,3)
        // console.log("array8: ",array8);



        let array9 = [1,2,3,4,5,6,7,8,9]
        console.log("array9: ",array9);
        console.log("array9.slice(2,4)； ", array9.slice(2,4));
        

        console.log(array9.fill(100));
        


      
        



        


    </script>



    <button onclick="sayHi()">点我</button>
</body>
</html>